import java.net.*;
import java.io.*;

	/**
	* @author Joshua Oberle.
	*/

public class LogClient {

	/**
	* This runs client from command line given the ip and port.
	*
	* This will pass lines of text to the server as they are received. Will end once the server receives nulls.
	*
	* @param args[0] The IP of the server.
	* @param args[1] The port to connect with.
	*/

    public static void main(String [] args) {
	String s=""; 
	if (args.length != 2){
	    //System.out.println("Usage: java ChatClient host port_number");
	    System.exit(1);
	}
	try {
	    Socket server = new Socket(args[0],Integer.parseInt(args[1]));
	    //System.out.println("Connected to ChatServer host  + server.getInetAddress());
	    BufferedReader fromServer = new BufferedReader
		(new InputStreamReader(server.getInputStream()));
	    PrintWriter toServer = new PrintWriter
		(server.getOutputStream(),true);
	    BufferedReader input = new BufferedReader(
						      new InputStreamReader(System.in));
          
	    while (s != null) {
		s=input.readLine();	// This is somewhat flawed since there
		// may be more than one line that the
		// server is broadcast
		toServer.println(s); 
	    }
	    fromServer.close();
	    toServer.close();
	    input.close();
	    server.close();
	}catch(Exception e) {
	    e.printStackTrace();
	}
    }
}           
